<?php include_once '../Model/AttachedFileDao.php';?>
<?php
    if(isset($_GET['id'])){
        $result = getContentFile($_GET['id']);
        $name = $result[0]['name'];
        $size = $result[0]['size'];
        $type = $result[0]['type'];
        $content = $result[0]['content'];

        
        if(strpos($type,'image')!== false){
            $mime = $type;
            $b64Src = "data:".$mime.";base64," . base64_encode($content);
            echo '<img class="center" src="'.$b64Src.'" alt="' . $name . '" />';
        } else {
            header("Content-length: $size");
            header('Content-Transfer-Encoding: binary');
            header("Content-type: $type");
            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            echo $content;
        }
    }

?>